
public class Test {
    public static void main(String[] args) throws InterruptedException {
        Object o1 = new Object();
        Object o2 = new Object();
        Thread a = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized(o2){
                    try {
                        o2.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("我是a线程");
                }
            }
        });
        a.start();
        Thread b = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized(o1){
                    try {
                        o1.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("我是b线程");
                    synchronized(o2){
                        o2.notify();
                    }
                }

            }
        });
        b.start();
        Thread c = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized(o1){
                    System.out.println("我是c线程");
                    o1.notify();
                }
            }
        });
        c.start();
    }
}
